<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\DB;
use App\Models\App;
use App\Models\Traits\AppOrdered;

class Item extends Model
{
	use AppOrdered;
	protected $guarded = [];
	protected $table = 'items';
	protected $primaryKey = 'name';
	protected $keyType = 'string';
	public $incrementing = false;

	public $casts = [];  //设置字段格式 


	/**
	 * 为路由模型获取键名。
	 *
	 * @return string
	*/ 
	public function getRouteKeyName()
	{
		return 'name';
	}

	public function apps()
	{
		return $this->hasMany(App::class,'item_name','name');
	}
}
